#coding:utf8
'''
'''

from framework.firefly_dc import runtime_logger as log
# from framework.dal.gameconfig.game_env import GameConfigEnv
from framework.dal.gameconfig.query import getProfile, getProfileList
from framework.firefly_dc.singleton import Singleton


class BaseComponent(object):
    """
    抽象的组件对象
    """
    __metaclass__ = Singleton

    def __init__(self, compomentCenter):
        '''创建一个组件
        '''
        self.cc = compomentCenter

    @staticmethod
    def getRoleProfile(table, **kwargs):
        """获取角色语言对应配置"""
        return getProfile(table, **kwargs)

    @staticmethod
    def getRoleProfileList(table, **kwargs):
        """获取角色语言对应多条配置"""
        return getProfileList(table, **kwargs)

    @staticmethod
    def log_err(err_msg):
        """
        写入错误日志
        :param err_msg:
        :return:
        """
        log.error(err_msg)

    @staticmethod
    def create_idx():
        """
        获取新的唯一主键
        :return:
        """
        from utils.unique_key import create_idx
        return create_idx()

    # @staticmethod
    # def get_cfg_env(key):
    #     """
    #     获取全局配置
    #     :param key:
    #     :return:
    #     """
    #     return getattr(GameConfigEnv(), key)

    # @staticmethod
    # def new_transaction(*args, **kwargs):
    #     """
    #     创建一个新的事务对象返回
    #     :param reraise_error: 提交的事务若执行失败是否抛出异常, 默认True
    #     :param propagation: ~~事务传播规则~~[不建议使用]
    #     """
    #     return TransactionDelegator(*args, **kwargs)

    # @staticmethod
    # def is_action_ver_gte_check_ver(check_ver):
    #     """
    #     接口版本号是否大于等于check_ver本号
    #     :param check_ver: type float eg 1.8
    #     :return:
    #     """
    #     return check_main_version(check_ver)
